package com.studentsystem.service.impl;

import com.studentsystem.dao.TeacherDao;
import com.studentsystem.dataobject.TeacherDO;
import com.studentsystem.service.TeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Teacher)表服务实现类
 */
@Service("teacherService")
public class TeacherServiceImpl implements TeacherService {
    @Resource
    private TeacherDao teacherDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TeacherDO queryById(String id) {
        return this.teacherDao.queryById(id);
    }

    @Override
    public TeacherDO queryByUsername(String username) {
        return this.teacherDao.queryByUsername(username);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TeacherDO> queryAllByLimit(int offset, int limit) {
        return this.teacherDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<TeacherDO> queryAll() {
        return this.teacherDao.queryAll(new TeacherDO());
    }

    @Override
    public List<TeacherDO> getTeachersByParam(String param) {
        return this.teacherDao.getTeachersByParam(param);
    }

    /**
     * 新增数据
     *
     * @param teacherDO 实例对象
     * @return 实例对象
     */
    @Override
    public Boolean insert(TeacherDO teacherDO) {
        return this.teacherDao.insert(teacherDO) > 0;
    }

    /**
     * 修改数据
     *
     * @param teacherDO 实例对象
     * @return Boolean
     */
    @Override
    public Boolean update(TeacherDO teacherDO) {
        return this.teacherDao.update(teacherDO) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.teacherDao.deleteById(id) > 0;
    }
}